import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";
export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  {
    path: "/myuser",
    component: Layout,
    redirect: "/myuser",
    children: [
      {
        path: "myuser",
        name: "myuser",
        component: () => import("@/views/myuser/index"),
        meta: { title: "个人中心", icon: "dashboard" },
      },
    ],
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },
  {
    path: "/dayin_liucheng",
    name: "dayin_liucheng",
    component: () => import("@/views/dayin_order/dayin_liuchengka"),
    hidden: true,
  },
  {
    path: "/dayin_renwu",
    name: "dayin_renwu",
    component: () => import("@/views/dayin_order/dayin_renwu"),
    hidden: true,
  },
  {
    path: "/dayin_chuhuo",
    name: "dayin_chuhuo",
    component: () => import("@/views/iFinishProductList/dayin"),
    hidden: true,
  },
  {
    path: "/kaoqindayin",
    name: "kaoqindayin",
    component: () => import("@/views/attendance/kaoqindayin"),
    hidden: true,
  },
  {
    path: "/gddayin",
    name: "gddayin",
    component: () => import("@/views/gongdandayin/gddayin"),
    hidden: true,
  },
  {
    path: "/biaoqian",
    name: "biaoqian",
    component: () => import("@/views/iFinishProductList/biaoqian"),
    hidden: true,
  },
  {
    path: "moxing",
    component: Layout,
    children: [
      {
        path: "/ziduanlist",
        name: "ziduanlist",
        component: () => import("@/views/moxing/ziduanlist"),
        hidden: true,
        meta: {
          title: "字段列表",
          noCache: true,
          activeMenu: "moxing/index",
        },
        alwaysShow: true,
      },
    ],
  },
  {
    path: "iFinishProductList",
    component: Layout,
    children: [
      {
        path: "/index_DS",
        name: "index_DS",
        component: () => import("@/views/iFinishProductList/index_DS"),
        hidden: true,
        meta: {
          title: "半成品详情",
          noCache: true,
          activeMenu: "iFinishProductList/index",
        },
        alwaysShow: true,
      },
      {
        path: "/index_more",
        name: "index_more",
        component: () => import("@/views/iFinishProductList/index_more"),
        hidden: true,
        meta: {
          title: "半成品=>产品=>型号列表",
          noCache: true,
          activeMenu: "iFinishProductList/index",
        },
        alwaysShow: true,
      },
      {
        path: "/index_more_xinghao",
        name: "index_more_xinghao",
        component: () =>
          import("@/views/iFinishProductList/index_more_xinghao"),
        hidden: true,
        meta: {
          title: "半成品=>产品=>型号列表",
          noCache: true,
          activeMenu: "iFinishProductList/index",
        },
        alwaysShow: true,
      },
      {
        path: "/index_more_yanse",
        name: "index_more_yanse",
        component: () => import("@/views/iFinishProductList/index_more_yanse"),
        hidden: true,
        meta: {
          title: "半成品=>产品=>颜色列表",
          noCache: true,
          activeMenu: "iFinishProductList/index",
        },
        alwaysShow: true,
      },
      {
        path: "/index_more_guige",
        name: "index_more_guige",
        component: () => import("@/views/iFinishProductList/index_more_guige"),
        hidden: true,
        meta: {
          title: "半成品=>产品=>规格列表",
          noCache: true,
          activeMenu: "iFinishProductList/index",
        },
        alwaysShow: true,
      },
    ],
  },
  {
    path: "/order_goods/dayin",
    name: "orderdayin",
    component: () => import("@/views/order_goods/dayin"),
    hidden: true,
    meta: {
      title: "打印合格证",
      noCache: true,
      activeMenu: "order_goods/index",
    },
    alwaysShow: true,
  },
  {
    path: "/getSalaryList/yggongzilist", //路径及携带参数
    component: () => import("@/views/getSalaryList/yggongzilist.vue"),
    // name: 'yggongzilist',
    // redirect:'noRedirect',
    //meta.activeMunu  激活时的菜单，新开的页面需要挂在那个菜单下
    meta: {
      title: "员工工资详情",
      noCache: true,
      activeMenu: "getSalaryList/index.vue",
    },
    hidden: true, //是否显示在菜单
  },
];

export const asyncRoutes = [];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
